@charset "utf-8";
@import "classes";
@import "../element/yo-btn";

/**
 * @class widget
 */

/**
 * 构造列表的自定义使用方法
 -----------------------
 * 使用方法，详见 [Demo](http://doyoe.github.io/Yo/demo/widget/yo-dialog.html)
 * @method yo-dialog
 * @param {default | String} $name 定义dialog名称
 * @param {default | Length | null} $width 定义dialog宽度
 * @param {default | Length} $height 定义dialog高度
 * @param {default | Length} $radius 定义dialog圆角
 * @param {default | Number} $shadow-opacity 定义dialog阴影透明度
 * @param {default | Color} $bordercolor 定义dialog边框色
 * @param {default | Length} $hd-height 定义dialog头部高度
 * @param {default | Color} $hd-bgcolor 定义dialog头部背景色
 * @param {default | Color} $title-color 定义dialog标题文本色
 * @param {default | Length} $title-font-size 定义dialog标题字号
 * @param {default | Length} $bd-padding 定义dialog主体补白
 * @param {default | Length} $bd-font-size 定义dialog主体字号
 */

@mixin yo-dialog(
    $name: default,
    $width: default,
    $height: default,
    $radius: default,
    $shadow-opacity: default,
    $bordercolor: default,
    $hd-height: default,
    $hd-bgcolor: default,
    $title-color: default,
    $title-font-size: default,
    $bd-padding: default,
    $bd-font-size: default) {
    // 区别是否新增实例还是修改本身
    @if $name == default {
        $name: "";
    } @else {
        $name: "-#{$name}";
    }
    // 如果值为default，则取config的定义
    @if $width == default {
        $width: map-get($dialog, width);
    }
    @if $height == default {
        $height: map-get($dialog, height);
    }
    @if $radius == default {
        $radius: map-get($dialog, radius);
    }
    @if $shadow-opacity == default {
        $shadow-opacity: map-get($dialog, shadow-opacity);
    }
    @if $bordercolor == default {
        $bordercolor: map-get($dialog, bordercolor);
    }
    @if $hd-height == default {
        $hd-height: map-get($dialog, hd-height);
    }
    @if $hd-bgcolor == default {
        $hd-bgcolor: map-get($dialog, hd-bgcolor);
    }
    @if $title-color == default {
        $title-color: map-get($dialog, title-color);
    }
    @if $title-font-size == default {
        $title-font-size: map-get($dialog, title-font-size);
    }
    @if $bd-padding == default {
        $bd-padding: map-get($dialog, bd-padding);
    }
    @if $bd-font-size == default {
        $bd-font-size: map-get($dialog, bd-font-size);
    }
    .yo-dialog#{$name} {
        @if $radius != map-get($dialog, radius) {
            border-radius: $radius;
        }
        @if $bordercolor != map-get($dialog, bordercolor) {
            border-color: $bordercolor;
            box-shadow: 0 0 5px rgba($bordercolor, $shadow-opacity);
        } @else {
            @if $shadow-opacity != map-get($dialog, shadow-opacity) {
                box-shadow: 0 0 5px rgba($bordercolor, $shadow-opacity);
            }
        }
        @if $width != map-get($dialog, width) {
            width: $width;
        }
        @if $height != map-get($dialog, height) {
            height: $height;
        }
        > .hd {
            @if $hd-height != map-get($dialog, hd-height) {
                height: $hd-height;
                line-height: $hd-height;
            }
            @if $hd-bgcolor != map-get($dialog, hd-bgcolor) {
                background: $hd-bgcolor;
            }
            .title {
                @if $title-color != map-get($dialog, title-color) and $title-color != map-get($base, color) {
                    color: $title-color;
                }
                @if $title-font-size != map-get($dialog, title-font-size) and $title-font-size != map-get($base, font-size) {
                    font-size: $title-font-size;
                }
            }
        }
        > .bd {
            @if $bd-padding != map-get($dialog, bd-padding) {
                padding: $bd-padding;
            }
            @if $bd-font-size != map-get($dialog, bd-font-size) and $bd-font-size != map-get($base, font-size) {
                font-size: $bd-font-size;
            }
        }
        // 增量扩展
        @content;
    }
}

// 调用本文件时载入dialog基础构造
.yo-dialog {
    @include _dialog;
}